1. Field of the Invention
The present invention relates to an apparatus which processes a digital image and a method therefor, and more particularly, to an apparatus which processes a digital image and a method therefor which can enlarge or reduce the digital image photographed by an image collecting apparatus such as a digital camera.
2. Description of the Related Art
FIG. 1 shows a conventional apparatus which processes a digital image. For example, digital image pixel data is input from a frame store memory (not shown) to the apparatus for digital image processing. The input digital image pixel data is interpolated by the apparatus, which processes the digital image, and output through a printer (not shown) or stored in another frame store memory (not shown) for a later processing.
The conventional apparatus which processes the digital image includes a controller 100, a vertical direction interpolation coefficient memory 101, a vertical direction interpolation input buffer 103, a vertical direction interpolation circuit 105, a vertical direction interpolation output buffer 107, a horizontal direction interpolation circuit 109, and a horizontal direction interpolation coefficient memory 111.
The controller 100 controls the vertical direction interpolation coefficient memory 101, the vertical direction interpolation input buffer 103, the vertical direction interpolation circuit 105, the vertical direction interpolation output buffer 107, the horizontal direction interpolation circuit 109, and the horizontal direction interpolation coefficient memory 111, so as to interpolate pixel values of the input digital image.
The vertical direction interpolation input buffer 103 temporarily stores the pixel values of the input digital image, and is embodied in a First-In First-Out (FIFO). Here, the FIFO is a method of processing program operation requests which processes a first request first (i.e., a firstly-input pixel value of the digital image).
At least one interpolation coefficient which creates an equation that represents a position of an output pixel, which is an interpolation node, is stored in the vertical direction interpolation coefficient memory 101 and the horizontal direction interpolation coefficient memory 111. The interpolation coefficients of the respective output pixel positions are calculated according to a distance between the pixel values of the input digital image, an increment interval between the pixel positions of the output digital image, and an interpolation method in the respective output pixel positions. In addition, a series of the pixel values of the input digital image are multiplied by the corresponding interpolation coefficients, thereby interpolating the pixel values of the input digital image.
When receiving a vertical direction interpolation processing signal by the controller 100, the vertical direction interpolation circuit 105 obtains vertical direction interpolation coefficients corresponding to the pixel values of the input digital image from the vertical direction interpolation coefficient memory 101, respectively multiplies the pixel values of the digital image by the vertical direction interpolation coefficients corresponding to the pixel values, and calculates a sum of the resulting values to perform the vertical direction interpolation. The pixel values of the digital image interpolated in a vertical direction by the vertical direction interpolation circuit 105 are stored in the vertical direction interpolation output buffer 107.
The horizontal direction interpolation circuit 109 receives the pixel values of the digital image interpolated in a vertical direction from the vertical direction interpolation output buffer 107. In addition, the horizontal direction interpolation circuit 109 obtains horizontal direction interpolation coefficients corresponding to the pixel values of the input digital image from the horizontal direction interpolation coefficient memory 111. Thereafter, the horizontal direction interpolation circuit 109 respectively multiplies the pixel values of the digital image interpolated in the vertical direction by the horizontal direction interpolation coefficients obtained from the horizontal direction interpolation coefficient memory 111, and calculates a sum of the resulting values to perform the horizontal direction interpolation. Accordingly, the horizontal and vertical direction interpolations of the pixel values of the input digital image are completed.
A variety of filters, such as bilinear, spline and cubic filters, which enlarge or reduce the digital image, are required to interpolate the digital image. Enlargement or reduction of the digital image by the filters should satisfy ideal filter properties. However, it is impossible to embody such an ideal filter. In FIG. 1, a sync function type filter is used, and a cubic convolution of FIG. 1 uses a shape shown in FIG. 2.
The convolution of FIG. 2 is represented by Formula 1:
                                          R            c                    ⁡                      (            x            )                          =                  (                                                                                          (                                          a                      +                      2                                        )                                    |                  x                  ⁢                                      |                    3                                    ⁢                                      -                                          (                                              a                        +                        3                                            )                                                        |                  x                  ⁢                                      |                    2                                    ⁢                                                                                    +                        1                                            ⁢                                                                                          ⁢                      …                      ⁢                                                                                          ⁢                      0                                        ≤                                    |                  x                  |                                      ≤                    1                                                                                                                        a                  |                  x                  ⁢                                      |                    3                                    ⁢                                                            -                      5                                        ⁢                    a                                    |                  x                  ⁢                                      |                    2                                    ⁢                                                            +                      8                                        ⁢                    a                                    |                  x                  |                                                                                    -                        4                                            ⁢                      a                      ⁢                                                                                          ⁢                      …                      ⁢                                                                                          ⁢                      1                                        ≤                                    |                  x                  |                                      ≤                    2                                                                                )                                    <                  Formula          ⁢                                          ⁢          1                >            wherein, when ‘a=−½’ is satisfied, Formula 1 is represented by Formula 2:
                              u          ⁡                      (            x            )                          =                  {                                                                                        ⁢                                                            3                      2                                        |                    x                    ⁢                                          |                      3                                        ⁢                                          -                                              5                        2                                                              |                    x                    ⁢                                          |                      2                                        ⁢                                                                                            +                          1                                                ⁢                                                                                                  ⁢                        …                        ⁢                                                                                                  ⁢                        0                                            <                                        |                    x                    |                                          <                      1                                                                                                                                                              ⁢                                                            -                                              1                        2                                                              |                    x                    ⁢                                          |                      3                                        ⁢                                          +                                              5                        2                                                              |                    x                    ⁢                                          |                      2                                        ⁢                                          -                      4                                        |                    x                    |                                                                                            +                          2                                                ⁢                                                                                                  ⁢                        …                        ⁢                                                                                                  ⁢                        1                                            <                                        |                    x                    |                                          <                      2                                                                                                                                                              ⁢                                                                                    0                        ⁢                                                                                                  ⁢                        …                        ⁢                                                                                                  ⁢                        2                                            <                                        |                    x                    |                                                                                                          <                  Formula          ⁢                                          ⁢          2                >            
FIG. 3 illustrates an interpolation method by the cubic convolution of FIG. 2. Assuming that an interval of the respective periods is ‘1’, an interpolation node Yp is represented by Formula 3 according to a boundary condition:
                              Y          p                =                  {                                                                                                                                        [                                                                                                            -                                                              1                                2                                                                                      ⁢                                                                                          (                                                                  1                                  +                                  t                                                                )                                                            2                                                                                +                                                                                    5                              2                                                        ⁢                                                                                          (                                                                  1                                  +                                  t                                                                )                                                            2                                                                                -                                                      4                            ⁢                                                          (                                                              1                                +                                t                                                            )                                                                                +                          2                                                ]                                            ⁢                                              Y                                                  k                          -                          1                                                                                      +                                                                                                                                                                  [                                                                                                            3                              2                                                        ⁢                                                                                          (                                t                                )                                                            3                                                                                -                                                                                    5                              2                                                        ⁢                                                          t                              2                                                                                +                          1                                                ]                                            ⁢                                              Y                        k                                                              +                                                                                                                                                                  [                                                                                                            3                              2                                                        ⁢                                                                                          (                                                                  1                                  -                                  t                                                                )                                                            3                                                                                -                                                                                    5                              2                                                        ⁢                                                          (                                                              1                                -                                                                  t                                  2                                                                                            )                                                                                +                          1                                                ]                                            ⁢                                              Y                                                  k                          +                          1                                                                                      +                                                                                                                                          [                                                                                                    -                                                          1                              2                                                                                ⁢                                                                                    (                                                              2                                -                                t                                                            )                                                        3                                                                          +                                                                              5                            2                                                    ⁢                                                                                    (                                                              2                                -                                t                                                            )                                                        2                                                                          -                                                  4                          ⁢                                                      (                                                          2                              -                              t                                                        )                                                                          +                        2                                            ]                                        ⁢                                          Y                                              k                        +                        2                                                                                                                                                                 <                  Formula          ⁢                                          ⁢          3                >            
Formula 4 is obtained by processing Formula 3 as a function of ‘t’. Here, Yk−1, Yk, Yk+1 and Yk+2 indicate positions of k−1, k, k+1 and k+2-th sampled output pixels of the input digital image, respectively.
                                                                                          Y                  p                                =                                ⁢                                                                            {                                                                        (                                                                                    Y                                                              k                                +                                2                                                                                      -                                                          3                              ⁢                                                              Y                                                                  k                                  +                                  1                                                                                                                      +                                                          3                              ⁢                                                              Y                                k                                                                                      -                                                          Y                                                              k                                -                                1                                                                                                              )                                                /                        2                                            }                                        ⁢                                          t                      3                                                        +                                                                                                                        ⁢                                                                            {                                                                        (                                                                                    -                                                              Y                                                                  k                                  +                                  2                                                                                                                      +                                                          4                              ⁢                                                              Y                                                                  k                                  +                                  1                                                                                                                      -                                                          5                              ⁢                                                              Y                                k                                                                                      +                                                          2                              ⁢                                                              Y                                                                  k                                  -                                  1                                                                                                                                              )                                                /                        2                                            }                                        ⁢                                          t                      2                                                        +                                                                                                                        ⁢                                                                            {                                                                        (                                                                                    Y                                                              k                                +                                2                                                                                      -                                                          2                              ⁢                                                              Y                                                                  k                                  -                                  1                                                                                                                                              )                                                /                        2                                            }                                        ⁢                    t                                    +                                      Y                    k                                                                                                                   <                  Formula          ⁢                                          ⁢          4                >            
Formula 5 is obtained by processing Formula 4:Yp=C1Yk−1+C2Yk+C3Yk+1+C4Yk+2C1=(−t3+2t2−t)/2C2=(3t3−5t2+2)/2C3=(−3t3+4t2+t)/2C4=(t3−t2)/2  <Formula 5>
Here, the respective coefficients C1, C2, C3 and C4 can use a lookup table.
However, when the apparatus is embodied in a form of hardware, in a scaler such as the cubic convolution, it takes a long processing time to apply the above Formula(s) to each scale value. In addition, as shown in FIG. 4, a lot of adders and multipliers are required to express the respective interpolation coefficients in the form of hardware. Thus, a bank is generally used as shown in FIG. 5. Here, the bank is a logical unit which divides a main memory device for management. The bank is used to prepare for an increase of the main memory device or to utilize a limited memory device space by bank switching. The more banks are used, the higher the performance. Although a small number of adders and multipliers are required when the banks are used, rather than the use of the Formula(s), so far as the memory is not infinite, the bank obtains approximate values. Accordingly, such an error influences the overall image quality. Moreover, buses are more frequently used due to memory access.
That is, in the cubic convolution using N banks, the respective banks are used with a representative value, thus generating an error. For example, when values between 0 and 1 are divided by five banks, the values are divided at an interval of 0.2. When Yp exists between 0 and 0.2, a distance ‘t’ between 0 and 1 in the cubic convolution filter is set up to be 0.1, to calculate the values C1, C2, C3 and C4. Accordingly, values between 0 and 0.2 are approximated to 0.1, which may generate an error. FIGS. 6A, 6B, 6C and 6D illustrate an error distribution of the cubic convolution of FIG. 3 and probable errors of the respective coefficients.
Referring to FIGS. 6A to 6D, the coefficients are divided by 1/N periods during N bank periods, and an error value of each period is reduced due to an increase of N. In addition, when the coefficients having errors are respectively multiplied by the pixel values, the interpolated pixel values have bigger errors. For example, assuming that ‘t’ is 0.19 and the pixel value of the digital image represented by (255 255 1 1) belongs to a first bank, the representative value of ‘t’ becomes 0.1, and thus the interpolated pixel value becomes 283. However, since ‘t’ is 0.19, the interpolated pixel value calculated by using the actual ‘t’ is 216. Accordingly, an error value of 67 is generated between the pixel value interpolated by the representative value of ‘t’ of the bank and the pixel value interpolated by the actual ‘t’.
FIG. 7 shows a flowchart illustrating a conventional method of processing a digital image. As shown in FIG. 7 with reference to FIG. 1, the controller 100 calculates a size ratio of the pixel value of the input digital image to an aimed pixel value to be interpolated by the vertical direction interpolation circuit 105 and the horizontal direction interpolation circuit 109 in operation 1001. That is, when the horizontal direction is X and the vertical direction is Y, X scale is X size of the original digital image/X size of the aimed digital image, and Y scale is Y size of the original digital image/Y size of the aimed digital image.
After calculating X and Y scales, the controller 100 measures Yk−1, Yk, Yk+1 and Yk+2 in operation 1003. Here, Yk−1, Yk, Yk+1 and Yk+2 indicate positions of the k−1, k, k+1 and k+2-th sampled output pixels of the input digital image, respectively. After measuring Yk−1, Yk, Yk+1 and Yk+2, the controller 100 obtains ‘t’ from the scale size in operation 1005. Here, ‘t’ represents an X axis interval between the pixel value of the input digital image and the interpolation node, namely an interpolation interval. After calculating ‘t’, the controller 100 obtains coefficients from the corresponding memories, the vertical direction interpolation coefficient memory 101 and the horizontal direction interpolation coefficient memory 111 according to ‘t’ in operation 1007. As described above, the vertical direction interpolation coefficient memory 101 and the horizontal direction interpolation coefficient memory 111 store the coefficients for variables which indicate the positions of the output pixels sampled in the interpolation node calculation equation.
The controller 100 calculates the interpolation node Yp according to the obtained coefficient in operation 1009. In addition, the controller 100 interpolates the input digital image by using the calculated interpolation node in operation 1011. Accordingly, interpolation of the input digital image is completed.
However, the conventional apparatus which processes the digital image and the method therefor require many adders and multipliers in a form of hardware, and also require many banks to obtain precise values. Moreover, when a number of the banks is restricted, the respective banks store the representative values of the interpolation intervals. As a result, an error is generated between the pixel value by the actual interpolation interval ‘t’ and the pixel value by the representative value thereof.